#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    return *(const char *)a - *(const char *)b;
}

void stringSort(char *string) {
    qsort(string, strlen(string), sizeof(char), compare);
}

void getUniqueSort(char *string, char *unique) {
    char letter[26] = {0};
    for(int i = 0; string[i]; i++) {
        letter[string[i] - 'a'] = 1;
    }
    int uniqueCount = 0;
    for(int i = 0; i < 26; i++) {
        if (letter[i] == 1) {
            unique[uniqueCount++] = 'a' + i;
        }
    }
    unique[uniqueCount] = '\0';
}

int main() {
    // step 1# 处理输入的两行字符串
    // 用 fgets 把字符串内容保存到变量
    // 用 strcspn 去除末尾换行
    // 用 strtok 分隔子字符串
    char line1[1000];
    char line2[1000];
    fgets(line1, sizeof(line1), stdin);
    fgets(line2, sizeof(line2), stdin);
    line1[strcspn(line1, "\n")] = '\0';
    line2[strcspn(line2, "\n")] = '\0';
    // step 1.1# 创建变量保存分割处理后的子字符串
    char puzzle[1000][25];
    int puzzleCount = 0;
    char dict[1000][25];
    int dictCount = 0;
    
    char *token = strtok(line1, ",");
    while(token != NULL) {
        strcpy(puzzle[puzzleCount++], token);
        token = strtok(NULL, ",");
    }
    token = strtok(line2, ",");
    while(token != NULL) {
        strcpy(dict[dictCount++], token);
        token = strtok(NULL, ",");
    }
    // step 3# 对分隔后的子字符串进行 全排序 和 去重全排序
    char puzzleSorted[1000][25];
    char puzzleUnique[1000][25];
    char dictSorted[1000][25];
    char dictUnique[1000][25];
    for(int i = 0; i < puzzleCount; i++) {
        strcpy(puzzleSorted[i], puzzle[i]);
        stringSort(puzzleSorted[i]);
        getUniqueSort(puzzle[i], puzzleUnique[i]);
    }
    for(int i = 0; i < dictCount; i++) {
        strcpy(dictSorted[i], dict[i]);
        stringSort(dictSorted[i]);
        getUniqueSort(dict[i], dictUnique[i]);
    }
    // step 4# 一层 for 遍历谜面 ； 一层 for 遍历谜底库
    int findCount = 0;
    for(int i = 0; i < puzzleCount; i++) {
        int isFind = 0;
        for(int j = 0; j < dictCount; j++) {
            if (strcmp(puzzleSorted[i], dictSorted[j]) == 0
                || strcmp(puzzleUnique[i], dictUnique[j]) == 0) {
                    findCount++;
                    isFind = 1;
                    if (findCount == 1) {
                        printf("%s", dict[j]);
                        break;
                    }
                    else {
                        printf(",%s", dict[j]);
                        break;
                    }
            }
        }
        if (i == 0 && isFind == 0) {
            printf("not found");
        }
        else if (i != 0 && isFind == 0) 
        printf(",not found");
    }

    return 0;
}